<template>
	<view>
		<view class="uni-margin-wrap">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration">
				<swiper-item v-for="item in img" :key="item.imgName">
					<u--image :src="item.imgName" :width="width+'px'" :height="height+'px'" style="position: relative;">
					</u--image>
					<u-button :text="item.text" :type="item.type" style="position: absolute;bottom: 80px;"
						@click="showIndex"></u-button>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			var width = 0;
			var height = 0;
			uni.getSystemInfo({
				success: function(res) {
					width = res.screenWidth;
					height = res.screenHeight;
				}
			});
			return {
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				img: [{
						imgName: '/static/img/1.jpg',
						type: 'hidden',
						text: ''
					},
					{
						imgName: '/static/img/5.jpg',
						type: 'hidden',
						text: ''
					},
					{
						imgName: '/static/img/3.jpg',
						type: 'hidden',
						text: ''
					},
					{
						imgName: '/static/img/4.jpg',
						type: 'hidden',
						text: ''
					},
					{
						imgName: '/static/img/2.jpg',
						type: 'success',
						text: '进入首页'
					},
				],
				width,
				height
			}
		},
		methods: {
			changeIndicatorDots(e) {
				this.indicatorDots = !this.indicatorDots
			},
			changeAutoplay(e) {
				this.autoplay = !this.autoplay
			},
			intervalChange(e) {
				this.interval = e.target.value
			},
			durationChange(e) {
				this.duration = e.target.value
			},
			showIndex() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		}
	}
</script>


<style>
	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
	}

	.swiper {
		height: 100vh;
	}

	.swiper-item {
		display: block;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
	}

	.swiper-list {
		margin-top: 40rpx;
		margin-bottom: 0;
	}

	.uni-common-mt {
		margin-top: 60rpx;
		position: relative;
	}

	.info {
		position: absolute;
		right: 20rpx;
	}

	.uni-padding-wrap {
		width: 550rpx;
		padding: 0 100rpx;
	}
</style>
